package com.cjd.view.corona;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextUtils;
import android.view.SurfaceHolder;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间轮盘控制器
 * Created by chenjidong on 2019/4/17.
 */
public class TimeCoronaController implements SurfaceHolder.Callback, Runnable {

    private static final int DEFAULT_RADIUS = 150;//默认半径
    private static final float DEFAULT_BEGIN_ANGLE = -90f;// 默认角度为 -90° 6点钟方向为起点

    private SurfaceHolder surfaceHolder;

    //添加挥之所需要的画笔、时间等
    private Canvas canvas; //画布
    private Paint paint; //绘制圆和刻度的画笔

    private int canvasWidth, canvasHeight; //画布的宽高
    private int radius;//时钟的半径
    private boolean isInit = true;//

    //时、分、秒
    private int hour, minute, second, year;
    private BigDecimal decimalSecondDegrees = BigDecimal.ZERO;
    private BigDecimal decimalMinuteDegrees = BigDecimal.ZERO;
    private BigDecimal decimalHourDegrees = BigDecimal.ZERO;

    private int initSecond = 0, initMinute, initHour;
    private boolean isMinuteMove, isHourMove, isSecondMove;

    private int normalColor, currentColor, backgroundColor;
    private int textSize;

    private String language = "zh_CN";
    private String[] secondItems, minuteItems, hourItems;//本地化时间 列表
    private float secondTextMaxWidth, minuteTextMaxWidth, hourTextMaxWidth;//文字最大宽度
    private int interval;//时间轮圈得间距
    private Context context;
    private int offsetX, offsetY;//已中心为起点偏移量
    private float beginAngleOffset = 0;//初始角度偏移量
    private String centerText;
    private final int fps = 25;//每秒钟 帧率

    //    private ScheduledExecutorService scheduledExecutorService;
    private Thread thread;
    private boolean flag; //用于标识surface销毁，停止绘制操作

    //秒 分 时 按360° 排列 每份的单位角度
    private final float secondUnitAngle = 360.0f / 60;
    private final float minuteUnitAngle = 360.0f / 60;
    private final float hourUnitAngle = 360.0f / 24;

    private float minRadius;//最小半径
    private int totalMillis = 0;//1秒 = 1000 毫秒
    private float scale = 1f;//缩放比例
    private OnTimeMoveListener onTimeMoveListener;
    //罗盘顶部标题 文字大小
    private int titleSize, titleCurrentTimeSize;
    private String currentTimeStr;//日期 星期
    private boolean showTitle = true;
    private int titleColor = Color.WHITE;
    private String textSegment1 = "就已经";
    private String textSegment3 = "了";
    private String textTitle = "明明什么都没做";


    public TimeCoronaController(Context context, SurfaceHolder surfaceHolder) {
        this.context = context;
        textSize = dp2px(context, 8);
        interval = dp2px(context, 6);
        radius = dp2px(context, DEFAULT_RADIUS);
        titleSize = dp2px(context, 24);
        titleCurrentTimeSize = dp2px(context, 48);

        this.surfaceHolder = surfaceHolder;
        this.canvasWidth = context.getResources().getDisplayMetrics().widthPixels;
        this.canvasHeight = context.getResources().getDisplayMetrics().heightPixels;
        surfaceHolder.addCallback(this);
        init();
    }

    /**
     * 是否显示顶部标题
     *
     * @param showTitle 默认true
     */
    public void setShowTitle(boolean showTitle) {
        this.showTitle = showTitle;
    }

    public void setOnTimeMoveListener(OnTimeMoveListener onTimeMoveListener) {
        this.onTimeMoveListener = onTimeMoveListener;
    }

    public Context getContext() {
        return context;
    }

    public void setCenterText(String centerText) {
        this.centerText = centerText;
    }

    public void setOffsetX(int offsetX) {
        this.offsetX = dp2px(context, offsetX);
    }

    public void setOffsetY(int offsetY) {
        this.offsetY = dp2px(context, offsetY);
    }

    public void setCanvasWidthAndHeight(int canvasWidth, int canvasHeight) {
        this.canvasWidth = canvasWidth;
        this.canvasHeight = canvasHeight;
    }

    /**
     * 初始显示角度，默认6点钟方向
     *
     * @param beginAngleOffset
     */
    public void setBeginAngleOffset(float beginAngleOffset) {
        this.beginAngleOffset = beginAngleOffset;
    }

    public void setRadius(int radius) {
        this.radius = dp2px(context, radius);
    }

    public int getNormalColor() {
        return normalColor;
    }

    public int getBackgroundColor() {
        return backgroundColor;
    }

    public void setBackgroundColor(int backgroundColor) {
        if (backgroundColor == 0)
            return;
        this.backgroundColor = backgroundColor;
    }

    /**
     * 罗盘半径
     * 负数表示减少
     *
     * @param radius 单位：dp
     */
    public void addRadius(int radius) {
        int defaultRadius = dp2px(context, DEFAULT_RADIUS);
        this.radius = defaultRadius + dp2px(context, radius);

        measureTextMaxWidth();
        if (this.radius < minRadius) {
            this.radius = (int) minRadius;
        }
    }

    /**
     * 缩放比例
     *
     * @param scale 默认1.0f
     */
    public void setScale(float scale) {
        this.scale = scale + 1f;
        if (this.scale <= 0f)
            this.scale = 0f;
    }

    public void setNormalColor(int normalColor) {
        if (normalColor == 0)
            return;
        this.normalColor = normalColor;
    }

    public void setCurrentColor(int currentColor) {
        if (currentColor == 0)
            return;
        this.currentColor = currentColor;
    }

    public int getCurrentColor() {
        return currentColor;
    }

    public void setTextSize(int textSize) {
        this.textSize = dp2px(context, textSize);
    }

    private void init() {
        normalColor = Color.parseColor("#A3A0A0");
        currentColor = Color.WHITE;
        backgroundColor = Color.BLACK;

        initTime();

        centerText = "";
        paint = new Paint();
        paint.setColor(normalColor);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.FILL);
        paint.setTextSize(textSize);
        paint.setTextAlign(Paint.Align.LEFT);


        secondItems = new String[]{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
                "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
                "二十一", "二十二", "二十三", "二十四", "二十五", "二十六", "二十七", "二十八",
                "二十九", "三十", "三十一", "三十二", "三十三", "三十四", "三十五", "三十六",
                "三十七", "三十八", "三十九", "四十", "四十一", "四十二", "四十三", "四十四",
                "四十五", "四十六", "四十七", "四十八", "四十九", "五十", "五十一", "五十二",
                "五十三", "五十四", "五十五", "五十六", "五十七", "五十八", "五十九"};
        minuteItems = secondItems;

        hourItems = new String[]{"二十四", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
                "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
                "二十一", "二十二", "二十三"};

        thread = new Thread(this);

        flag = true;
        thread.start();
//        scheduledExecutorService = Executors.newScheduledThreadPool(1);
//        scheduledExecutorService.scheduleAtFixedRate(this, 0, 1000 / 25, TimeUnit.MILLISECONDS);

    }

    private void initTime() {
        //初始化当前显示的时间
        year = Calendar.getInstance().get(Calendar.YEAR);
        hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        minute = Calendar.getInstance().get(Calendar.MINUTE);
//        minute = 59;
        second = Calendar.getInstance().get(Calendar.SECOND);
//        second = 55;

        decimalSecondDegrees = BigDecimal.ZERO;
        decimalMinuteDegrees = BigDecimal.ZERO;
        decimalHourDegrees = BigDecimal.ZERO;
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MM/dd");
        currentTimeStr = format.format(date);
        currentTimeStr = currentTimeStr + " " + getWeek(date);
        totalMillis = 0;
    }

    /**
     * 首次创建 surfaceCreated 不会回调，兼容app 返回桌面
     *
     * @param init true
     */
    private void setInit(boolean init) {
        isInit = init;
        initTime();
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        System.out.println("--->surfaceCreated");
        setInit(true);
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        System.out.println("--->surfaceChanged");

    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        System.out.println("--->surfaceDestroyed");

    }

    public void onDestroy() {
        flag = false;
        if (thread != null) {
            thread = null;
        }
    }

    @Override
    public void run() {


        /*---线程池 start---*/
//        draw();
//        int interval = 1000 / 25;//每秒25帧
//        delay += interval;
//        if (delay == 1000) {
//            delay = 0;
//            logic();
//        }
        /*---end---*/

        /*---单线程 实现 start ---*/
        long start;
        long end;
//        logic();
        while (flag) {
            start = System.currentTimeMillis();

            draw();
            end = System.currentTimeMillis();

            try {
                int interval = 500 / fps;
                if (end - start < interval) {
                    long millis = interval - (end - start);
                    if (millis > 0)
                        Thread.sleep(millis);
                }
                totalMillis += interval;

                //卡顿效果
                if (totalMillis == 500) {
                    start = System.currentTimeMillis();
                    totalMillis = 0;
                    isSecondMove = false;

                    //旋转动画完毕后 设置真实的初始化时间
                    if (isMinuteMove) {
                        isMinuteMove = false;
                        initMinute = minute;
                    }
                    if (isHourMove) {
                        isHourMove = false;
                        initHour = hour;
                    }
                    draw();
                    end = System.currentTimeMillis();
//                    System.out.println("--->sleep:" + (500 - (end - start)));
                    long millis = 500 - (end - start);
                    if (millis > 0)
                        Thread.sleep(millis);
                    isSecondMove = true;
                    logic();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        /*---end---*/
    }


    /**
     * 时间计算
     */
    private void logic() {
//        hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
//        minute = Calendar.getInstance().get(Calendar.MINUTE);
//        second = Calendar.getInstance().get(Calendar.SECOND);
        second++;
        if (onTimeMoveListener != null)
            onTimeMoveListener.onMove(0, second);
        isMinuteMove = second == 60;

        if (second == 60) {

            second = 0;
            minute++;

            if (onTimeMoveListener != null)
                onTimeMoveListener.onMove(1, minute);

            isHourMove = minute == 60;
            if (minute == 60) {
                minute = 0;
                hour++;

                if (onTimeMoveListener != null)
                    onTimeMoveListener.onMove(2, hour);

                if (hour == 24) {
                    hour = 0;
                }
            }
        }

        if (!isMinuteMove)
            initMinute = minute;
        if (!isHourMove)
            initHour = hour;
    }


    private void draw() {
//        System.out.println("--->开始绘制");
        try {

            canvas = surfaceHolder.lockCanvas(); // 得到画布

            if (canvas != null) {

                //刷屏
                canvas.drawColor(backgroundColor);
                drawCorona();

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (canvas != null && surfaceHolder.getSurface().isValid()) {
                    surfaceHolder.unlockCanvasAndPost(canvas);
                }
            } catch (IllegalStateException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 中心水平线
     */
    private void drawVerticalAndHorizontalLine() {
        // 水平线
        paint.setColor(Color.RED);
        canvas.drawLine(0, 0, radius * 2.0f, 0, paint);
        canvas.drawLine(0, 0, -radius * 2.0f, 0, paint);

        //垂直线
        canvas.drawLine(0, 0, 0, radius * 2.0f, paint);
        canvas.drawLine(0, 0, 0, -radius * 2.0f, paint);

        //中心圆
//        paint.setColor(Color.BLUE);
//        paint.setStyle(Paint.Style.STROKE);
//        canvas.drawCircle(0, 0, remaining - interval, paint);

    }

    /**
     * 显示顶部 文字 及时间
     */
    private void drawTopTitle() {
        int centerX = canvasWidth / 2;
        int centerY = canvasHeight / 2;
        paint.setTextSize(titleSize);
        paint.setColor(titleColor);
        String textDate = currentTimeStr;
        float textDateWidth = paint.measureText(textDate);
        Rect rectDate = new Rect();
        paint.getTextBounds(textDate, 0, textDate.length(), rectDate);
        canvas.drawText(textDate, -textDateWidth / 2, -radius + -interval * 2, paint);

        canvas.translate(-centerX, -centerY);//移动坐标到左上角开始计算(0,0)

        paint.setTextSize(titleSize);


        Rect rectSegment1 = new Rect();
        Rect rectSegment3 = new Rect();
        paint.getTextBounds(textSegment1, 0, textSegment1.length(), rectSegment1);
        paint.getTextBounds(textSegment3, 0, textSegment3.length(), rectSegment3);

        float textSegment1Width = rectSegment1.width();
        float textSegment3Width = rectSegment3.width();

        paint.setTextSize(titleCurrentTimeSize);
        String hourStr = hour < 10 ? "0" + hour : "" + hour;
        String minuteStr = minute < 10 ? "0" + minute : "" + minute;
        String textSegment2 = hourStr + ":" + minuteStr;

        Rect rectSegment2 = new Rect();
        paint.getTextBounds(textSegment2, 0, textSegment2.length(), rectSegment2);

        //左边剩余的 宽度
        float leftInterval = (canvasWidth - textSegment1Width - textSegment3Width - rectSegment2.width()) / 2 - interval * 2;

        // "就已经" 文字坐标
        float segment1X = leftInterval + rectSegment2.height() * 1f / 2;
        float segment1Y = (centerY - (radius + interval * 3 + rectDate.height())) - rectSegment2.height() * 1f / 2 + rectSegment3.height() * 1f / 2;
        paint.setTextSize(titleSize);
        canvas.drawText(textSegment1, segment1X, segment1Y, paint);

        //"超大文字"
        float segment2X = segment1X + textSegment1Width + interval;
        float segment2Y = centerY - (radius + interval * 3 + rectDate.height());

        paint.setTextSize(titleCurrentTimeSize);
        canvas.drawText(textSegment2, segment2X, segment2Y, paint);

        //“了" 文字
        float segment3X = segment2X + rectSegment2.width() + interval * 2;
        float segment3Y = (centerY - (radius + interval * 3 + rectDate.height())) - rectSegment2.height() * 1f / 2 + rectSegment3.height() * 1f / 2;
        paint.setTextSize(titleSize);
        canvas.drawText(textSegment3, segment3X, segment3Y, paint);

        //顶部标题 恢复中心点坐标
        canvas.translate(centerX, centerY);
        float textTitleWidth = paint.measureText(textTitle);
        float titleY = -radius + -interval * 4 + -rectSegment1.height() + -rectSegment2.height();
        paint.setTextSize(titleSize);
        canvas.drawText(textTitle, -textTitleWidth / 2, titleY, paint);
    }

    /**
     * 绘制罗盘
     */
    private void drawCorona() {

        if (showTitle) {
            canvas.translate(canvasWidth * 1f / 2, canvasHeight * 1f / 2);
//            drawVerticalAndHorizontalLine();
            drawTopTitle();
        }

        float centerX = canvasWidth * 1f / 2 + offsetX;
        float centerY = canvasHeight * 1f / 2 + offsetY;

        if (isInit) {
            initSecond = second;
            initMinute = minute;
            initHour = hour;
        }

        measureTextMaxWidth();


        Matrix matrixText = new Matrix();
        matrixText.postScale(scale, scale, centerX, centerY);
        canvas.setMatrix(matrixText);

        paint.setColor(currentColor);
        float remaining = radius - (hourTextMaxWidth + minuteTextMaxWidth + secondTextMaxWidth + interval * 2);

        //计算文字大小 及位置
        if (!TextUtils.isEmpty(centerText)) {
            paint.setTextSize((float) (remaining * Math.sqrt(2)));//剩余半径 *2 = 周长
            Rect rect = new Rect();

            Paint.FontMetrics fontMetrics = paint.getFontMetrics();
            float fontHeight = fontMetrics.bottom - fontMetrics.top;

            paint.getTextBounds(centerText, 0, centerText.length(), rect);

            int textWidth = rect.width();
            int textHeight = rect.height();
            float textBaseY = textHeight - (textHeight * 1f - fontHeight) / 2 - fontMetrics.bottom;

            canvas.drawText(centerText, centerX + (-textWidth * 1f / 2), centerY + (textBaseY / 2), paint);
        }


        paint.setStyle(Paint.Style.FILL);
        paint.setTextSize(textSize);

        //绘制小时
        float hourDegrees = getWillMoveAngle(2);

        Matrix matrixHour = new Matrix();
        matrixHour.postRotate(DEFAULT_BEGIN_ANGLE + (initHour * hourUnitAngle) + hourDegrees + beginAngleOffset, centerX, centerY);
        matrixHour.postScale(scale, scale, centerX, centerY);
        canvas.setMatrix(matrixHour);

        canvas.translate(centerX, centerY);

        for (int i = 0; i < hourItems.length; i++) {

            String text = getLocalNumber(2, i);
            canvas.save();
            canvas.translate(0, radius - ((hourTextMaxWidth + minuteTextMaxWidth + secondTextMaxWidth) + interval * 2));
            canvas.rotate(90);
            if (hour == i && !isHourMove) {
                paint.setColor(currentColor);
            } else paint.setColor(normalColor);

            canvas.drawText(text, 0, 0, paint);
            canvas.restore();

            canvas.rotate(-hourUnitAngle);
        }
//
        //绘制 分
        float minuteDegrees = getWillMoveAngle(1);

        Matrix matrixMinute = new Matrix();
        matrixMinute.postRotate(DEFAULT_BEGIN_ANGLE + (initMinute * minuteUnitAngle) + minuteDegrees + beginAngleOffset, centerX, centerY);
        matrixMinute.postScale(scale, scale, centerX, centerY);

        canvas.setMatrix(matrixMinute);

        canvas.translate(centerX, centerY);


        for (int i = 0; i < minuteItems.length; i++) {

            String text = getLocalNumber(1, i);
            canvas.save();
            canvas.translate(0, radius - ((minuteTextMaxWidth + secondTextMaxWidth) + interval));
            canvas.rotate(90);
            if (minute == i && !isMinuteMove) {
                paint.setColor(currentColor);
            } else paint.setColor(normalColor);

            if (i == 0)
                text = "";

            canvas.drawText(text, 0, 0, paint);
            canvas.restore();


            canvas.rotate(-minuteUnitAngle);
        }

        //绘制秒
        float secondDegrees = getWillMoveAngle(0);
        Matrix matrix = new Matrix();
        matrix.postRotate(DEFAULT_BEGIN_ANGLE + ((initSecond) * secondUnitAngle) + secondDegrees + beginAngleOffset, centerX, centerY);
        matrix.postScale(scale, scale, centerX, centerY);
        canvas.setMatrix(matrix);

        canvas.translate(centerX, centerY);

        for (int i = 0; i < secondItems.length; i++) {

            String text = getLocalNumber(0, i);
            canvas.save();
            canvas.translate(0, radius - secondTextMaxWidth);
            canvas.rotate(90);

            if (second == i && !isSecondMove) {
                paint.setColor(currentColor);
            } else {
                paint.setColor(normalColor);
            }
            if (i == 0)
                text = "";
            canvas.drawText(text, 0, 0, paint);

            canvas.restore();
            canvas.rotate(-secondUnitAngle);//逆时针绘制
        }


        if (isInit) {
            isInit = false;
        }
    }

    /**
     * tips：minute 和 hour 非旋转状态下是 必须返回 0，否则造成初始角度偏移
     * 计算需要移动的角度
     *
     * @param type 0 秒 1分 2小时
     * @return
     */
    private float getWillMoveAngle(int type) {
        if (type == 0) {
            float willAngle = secondUnitAngle / fps;//单次移动的角度 0.24
            if (isSecondMove)//移动状态
                decimalSecondDegrees = decimalSecondDegrees.add(new BigDecimal(willAngle));

            float secondDegrees = decimalSecondDegrees.setScale(4, RoundingMode.HALF_UP).floatValue();
            if (secondDegrees >= 360f || isInit) {
                decimalSecondDegrees = BigDecimal.ZERO;
            }
            return secondDegrees;
        } else if (type == 1) {

            float willAngle = minuteUnitAngle / fps;//单次移动的角度 0.24
            if (isMinuteMove) {//移动状态
                decimalMinuteDegrees = decimalMinuteDegrees.add(new BigDecimal(willAngle));

                float minuteDegrees = decimalMinuteDegrees.setScale(4, RoundingMode.HALF_UP).floatValue();
                if (minuteDegrees >= minuteUnitAngle || isInit) {
                    decimalMinuteDegrees = BigDecimal.ZERO;
                }
                return minuteDegrees;
            }
        } else if (type == 2) {
            float willAngle = hourUnitAngle / fps;//单次移动的角度 0.6
            if (isHourMove) {//移动状态
                decimalHourDegrees = decimalHourDegrees.add(new BigDecimal(willAngle));

                float hourDegrees = decimalHourDegrees.setScale(4, RoundingMode.HALF_UP).floatValue();
                if (hourDegrees >= hourUnitAngle || isInit) {
                    decimalHourDegrees = BigDecimal.ZERO;
                }
                return hourDegrees;
            }
        }
        return 0f;
    }

    private String getLocalNumber(int type, int index) {
        if (type == 0) {
            String value = language.equalsIgnoreCase("zh_CN") ? secondItems[index] : index + "";
            return value + getTimeUnit(type);
        } else if (type == 1) {
            String value = language.equalsIgnoreCase("zh_CN") ? minuteItems[index] : index + "";

            return value + getTimeUnit(type);
        } else if (type == 2) {
            String value = language.equalsIgnoreCase("zh_CN") ? hourItems[index] : index + "";
            return value + getTimeUnit(type);
        }

        return String.valueOf(index);
    }

    /**
     * 获取国际化时间单位
     *
     * @param type
     * @return
     */
    private String getTimeUnit(int type) {
        if (type == 0) {
            return language.equalsIgnoreCase("zh_CN") ? "秒" : "s";
        } else if (type == 1) {
            return language.equalsIgnoreCase("zh_CN") ? "分" : "m";
        } else if (type == 2) {
            return language.equalsIgnoreCase("zh_CN") ? "点" : "h";
        }

        return "";
    }

    /**
     * 测量最长文字的 width
     */
    private void measureTextMaxWidth() {
        paint.setTextSize(textSize);
        String maxText = "";
        for (String value : secondItems) {
            if (value.length() > maxText.length())
                maxText = value;
        }
        secondTextMaxWidth = paint.measureText(maxText + getTimeUnit(0));

        String maxText1 = "";
        for (String value : minuteItems) {
            if (value.length() > maxText1.length())
                maxText1 = value;
        }
        minuteTextMaxWidth = paint.measureText(maxText1 + getTimeUnit(1));

        String maxText2 = "";
        for (String value : minuteItems) {
            if (value.length() > maxText2.length())
                maxText2 = value;
        }
        hourTextMaxWidth = paint.measureText(maxText2 + getTimeUnit(2));

        minRadius = secondTextMaxWidth + minuteTextMaxWidth + hourTextMaxWidth + interval * 3;
    }

    public static int dp2px(Context context, float dpValue) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    public static int px2dip(Context context, float pxValue) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }


    public static String getWeek(Date date) {
        String[] weeks = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (week_index < 0) {
            week_index = 0;
        }
        System.out.println(weeks[week_index]);
        return weeks[week_index];
    }

    /**
     * 时间计数回调
     */
    public interface OnTimeMoveListener {
        /**
         * @param type 0 秒 1 分 2 小时
         * @param time int
         */
        void onMove(int type, int time);
    }
}
